% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replication "Deconstructing the Yield Curve"
% Crump and Gospodinov (2024)
% Date: 26-JUL-2024
% Code to make csv file for Table 8
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;

fullSampleBR = load('../output/BR_B5000_BRdata1_rstarCPI0_197104_201801');

bootstrapFullSample = strings(9,7);
bootstrapFullSample(:,1) = ["Est. Coeffs.", "$\pi^*$", "$r^*$", "BH ($p$-val)", "$\pi^*$", "$r^*$", "CG ($p$-val)", "$\pi^*$", "$r^*$"];
boostrapBRsubsample = strings(9,7);
boostrapBRsubsample(:,1) = ["Est. Coeffs.", "$\pi^*$", "$r^*$", "BH ($p$-val)", "$\pi^*$", "$r^*$", "CG ($p$-val)", "$\pi^*$", "$r^*$"];
%
dispPref = '%3.2f';

bootstrapFullSample(2,2) = num2str(round(fullSampleBR.betaHat1(5),2),dispPref);
bootstrapFullSample(2,3) = num2str(round(fullSampleBR.betaHat2(5),2),dispPref);
bootstrapFullSample(3,3) = num2str(round(fullSampleBR.betaHat2(6),2),dispPref);
bootstrapFullSample(3,4) = num2str(round(fullSampleBR.betaHat3(5),2),dispPref);
%
bootstrapFullSample(2,5) = num2str(round(fullSampleBR.betaHat41(5),2),dispPref);
bootstrapFullSample(2,6) = num2str(round(fullSampleBR.betaHat42(5),2),dispPref);
bootstrapFullSample(3,6) = num2str(round(fullSampleBR.betaHat42(6),2),dispPref);
bootstrapFullSample(3,7) = num2str(round(fullSampleBR.betaHat43(5),2),dispPref);
%
bootstrapFullSample(5,2) = num2str(round(fullSampleBR.pval1_BH(5),2),dispPref);
bootstrapFullSample(5,3) = num2str(round(fullSampleBR.pval2_BH(5),2),dispPref);
bootstrapFullSample(6,3) = num2str(round(fullSampleBR.pval2_BH(6),2),dispPref);
bootstrapFullSample(6,4) = num2str(round(fullSampleBR.pval3_BH(5),2),dispPref);
%
bootstrapFullSample(5,5) = num2str(round(fullSampleBR.pval41_BH(5),2),dispPref);
bootstrapFullSample(5,6) = num2str(round(fullSampleBR.pval42_BH(5),2),dispPref);
bootstrapFullSample(6,6) = num2str(round(fullSampleBR.pval42_BH(6),2),dispPref);
bootstrapFullSample(6,7) = num2str(round(fullSampleBR.pval43_BH(5),2),dispPref);
%
bootstrapFullSample(8,2) = num2str(round(fullSampleBR.pval1(5),2),dispPref);
bootstrapFullSample(8,3) = num2str(round(fullSampleBR.pval2(5),2),dispPref);
bootstrapFullSample(9,3) = num2str(round(fullSampleBR.pval2(6),2),dispPref);
bootstrapFullSample(9,4) = num2str(round(fullSampleBR.pval3(5),2),dispPref);
%
bootstrapFullSample(8,5) = num2str(round(fullSampleBR.pval41(5),2),dispPref);
bootstrapFullSample(8,6) = num2str(round(fullSampleBR.pval42(5),2),dispPref);
bootstrapFullSample(9,6) = num2str(round(fullSampleBR.pval42(6),2),dispPref);
bootstrapFullSample(9,7) = num2str(round(fullSampleBR.pval43(5),2),dispPref);
%
boostrapBRsubsample(2,2) = num2str(round(fullSampleBR.betaHat1_sub(5),2),dispPref);
boostrapBRsubsample(2,3) = num2str(round(fullSampleBR.betaHat2_sub(5),2),dispPref);
boostrapBRsubsample(3,3) = num2str(round(fullSampleBR.betaHat2_sub(6),2),dispPref);
boostrapBRsubsample(3,4) = num2str(round(fullSampleBR.betaHat3_sub(5),2),dispPref);
%
boostrapBRsubsample(2,5) = num2str(round(fullSampleBR.betaHat41_sub(5),2),dispPref);
boostrapBRsubsample(2,6) = num2str(round(fullSampleBR.betaHat42_sub(5),2),dispPref);
boostrapBRsubsample(3,6) = num2str(round(fullSampleBR.betaHat42_sub(6),2),dispPref);
boostrapBRsubsample(3,7) = num2str(round(fullSampleBR.betaHat43_sub(5),2),dispPref);
%
boostrapBRsubsample(5,2) = num2str(round(fullSampleBR.pval1_sub_BH(5),2),dispPref);
boostrapBRsubsample(5,3) = num2str(round(fullSampleBR.pval2_sub_BH(5),2),dispPref);
boostrapBRsubsample(6,3) = num2str(round(fullSampleBR.pval2_sub_BH(6),2),dispPref);
boostrapBRsubsample(6,4) = num2str(round(fullSampleBR.pval3_sub_BH(5),2),dispPref);
%
boostrapBRsubsample(5,5) = num2str(round(fullSampleBR.pval41_sub_BH(5),2),dispPref);
boostrapBRsubsample(5,6) = num2str(round(fullSampleBR.pval42_sub_BH(5),2),dispPref);
boostrapBRsubsample(6,6) = num2str(round(fullSampleBR.pval42_sub_BH(6),2),dispPref);
boostrapBRsubsample(6,7) = num2str(round(fullSampleBR.pval43_sub_BH(5),2),dispPref);
%
boostrapBRsubsample(8,2) = num2str(round(fullSampleBR.pval1_sub(5),2),dispPref);
boostrapBRsubsample(8,3) = num2str(round(fullSampleBR.pval2_sub(5),2),dispPref);
boostrapBRsubsample(9,3) = num2str(round(fullSampleBR.pval2_sub(6),2),dispPref);
boostrapBRsubsample(9,4) = num2str(round(fullSampleBR.pval3_sub(5),2),dispPref);
%
boostrapBRsubsample(8,5) = num2str(round(fullSampleBR.pval41_sub(5),2),dispPref);
boostrapBRsubsample(8,6) = num2str(round(fullSampleBR.pval42_sub(5),2),dispPref);
boostrapBRsubsample(9,6) = num2str(round(fullSampleBR.pval42_sub(6),2),dispPref);
boostrapBRsubsample(9,7) = num2str(round(fullSampleBR.pval43_sub(5),2),dispPref);

writematrix([bootstrapFullSample boostrapBRsubsample(:,2:end)], '../output/bootstrapTableBR.csv');



